﻿<Chart OnInit="@(() => OnInit(LineDatasetCount, LineDataCount))" />

@code{
    private Task<ChartDataSource> OnInit(int dsCount, int daCount)
    {
        var ds = new ChartDataSource();
        ds.Options.XAxes.Add(new ChartAxes() { LabelString = "天数" });
        ds.Options.YAxes.Add(new ChartAxes() { LabelString = "数值" });

        ds.Labels = Enumerable.Range(1, daCount).Select(i => i.ToString());

        for (var index = 0; index < dsCount; index++)
        {
            ds.Data.Add(new ChartDataset()
            {
                Label = $"数据集 {index}",
                Data = Enumerable.Range(1, daCount).Select(i => Random(20, 37)).Cast<object>()
            });
        }
        return Task.FromResult(ds);
    }
}